package com.epam.necklace.logic.activity;

import java.util.Collections;
import java.util.Comparator;

import org.apache.log4j.Logger;

import com.epam.necklace.model.stone.Stone;

public class PriseComparator implements Comparator<Stone> {
	private static final Logger log = Logger.getLogger(PriseComparator.class);

	@Override
	public int compare(Stone o1, Stone o2) {
		double stone1prise = o1.getPrise();
		double stone2prise = o2.getPrise();

		if (stone1prise > stone2prise)
			return -1;
		else if (stone1prise < stone2prise)
			return 1;
		else
			return 0;
	}

	public void action() {
		Collections.sort(Necklace.necklace, new PriseComparator());
		StringBuilder output = new StringBuilder();
		output.append("Your necklace after sorting-");
		for (Stone beads : Necklace.necklace) {
			output.append(beads.toString()).append(",");
		}
		log.info(output);
	}
}
